home *** CD-ROM | disk | FTP | other *** search
/ United Public Domain Gold 2 / United Public Domain Gold 2.iso / utilities / pu494.dms / pu494.adf / MANDDEMO / arexx / IterMovie.mnd2 < prev    next >
Text File  |  1993-08-18  |  9KB  |  254 lines

  1. /* This script is supplied with the Mand2000 demo and release */
  2. /* versions and may be freely distributed. */
  3.  
  4. /* An ARexx programming for creating iteration movies. */
  5.  
  6. /*
  7.     When Mand2000 calculates a picture, it stores the iteration counts
  8. for each pixel, memory permitting.  This means that if you calculate a
  9. movie at an iteration count of, say, 1000, Mand2000 can redisplay that
  10. picture the way it would look with an iteration count of any number under
  11. 1000, without doing any recalculating.  This script makes use of that
  12. features to allow fast and easy creation of iteration movies.  These
  13. animations can look quite impressive, as fractal fingers gradually take
  14. over the black screen.
  15.  
  16.     This script asks the user for some input to help it create a
  17. reasonable movie.  The first thing it asks for is the final iteration
  18. count.  After that it asks the user for the starting iteration count.  For
  19. best results let the picture completely calculate at the final iteration
  20. count before you set it to the starting iteration count.  Typically you
  21. want the final iteration count to have pretty much all of the colour that
  22. is going to appear be there.  Typically you want the start iteration count
  23. to make the picture black.
  24.  
  25.     When you've set these values the script tells Mand2000 to keep
  26. redrawing the picture starting at the low iteration count and working up.
  27. The successive frames are saved to the Ram Disk as ITERFRAME10001 and
  28. upwards.  The base frame name can be changed by editing this script.  If
  29. the iterations are changing too quickly, or too slowly, you can adjust the
  30. IterInc, SpeedUpPoint and IncDivisor values to tune your movie.
  31.     IterInc is the initial amount by which the iterations are
  32. incremented after each frame.
  33.     SpeedUpPoint is the iteration count at which the iteration level
  34. starts changing faster.
  35.     IncDivisor adjusts how quickly the increase speeds up.  Smaller
  36. numbers make it increase faster.
  37.  
  38.     Because Mand2000 is live the whole time this movie is being
  39. generated, you can also adjust things on the fly.  If the final stages are
  40. obviously taking too long you can use the max iterations requester to
  41. manually increase the iterations, thus cutting out some of the unecessary
  42. frames.
  43.  
  44.     The resulting sequence of frames can be easily loaded into DPaint
  45. or any other program for creating animations.
  46.  
  47.     This script will, optionally, use ADPro to create an animation file out
  48. of  the  individual  frames  as  they  are  generated.  This saves time and
  49. reduces  the  user  intervention  required to create a movie.  Also, if the
  50. script  were  modified  so  that the frames were deleted off of the disk as
  51. soon  as  they had been put into the Anim, the disk space required would be
  52. reduced.
  53.     */
  54.  
  55. portname = address()    /* Retrieve the current port name. */
  56. /* If the portname does not start with MAND2000 then this script must */
  57. /* have been run with rx, rather than from Mand2000.  Therefore we */
  58. /* need to set the port name.  We do not always set the port name */
  59. /* because it is better to let Mand2000 set it for us, so that */
  60. /* this script can be used with windows other than the one with */
  61. /* port name MAND2000.1. */
  62. if (left(portname, 8) ~= "MAND2000") THEN
  63.     address 'MAND2000.1'
  64.  
  65. options results
  66.  
  67. /* Settings for all the way out. */
  68. IterInc = 2
  69. SpeedUpPoint = 90
  70. IncDivisor = 9
  71.  
  72. /* Settings for spiral galaxy. */
  73. /*IterInc = 2
  74. SpeedUpPoint = 90
  75. IncDivisor = 9*/
  76.  
  77. /* Settings for double spiral. */
  78. /*IterInc = 25
  79. SpeedUpPoint = 3500
  80. IncDivisor = 6*/
  81.  
  82.  
  83. /* Parse out the command option.  This script is called when the */
  84. /* user wants a movie started, when the user wants a movie */
  85. /* aborted and whenever one of the pictures in the sequence is done.  */
  86.  
  87. parse arg command
  88.  
  89. if (command = START) then
  90.     StartIterMovie()
  91. else if (command = STOP) then
  92.     StopIterMovie()
  93. else
  94.     ContinueIterMovie()
  95.  
  96. Exit
  97.  
  98.  
  99.  
  100. StartIterMovie:
  101.     DECPAUSE        /* Allow Mand2000 to resume calculating while this script executes. */
  102.     REQUESTER MAXITERS    /* See whether the maxiters requester is up already. */
  103.     maxitersstate = RESULT
  104.     REQUESTER MAXITERS ON    /* Force it to be up regardless. */
  105.     REQUESTNOTIFY "This ARexx script makes an|animation by having the maximum|iterations of a fractal picture|increase from frame to frame.|Select `Continue' on this|requester when you have set max|iters to the desired finish value.|You should set it to the smallest|value that causes all, or almost|all, coloured pixels to be filled|in, then wait for the picture to|finish calculating before|selecting `Continue'."
  106.     GETATTR application stem PROJ
  107.     SETCLIP("Mand2000IterEnd", PROJ.MAXITERS)
  108.  
  109.     /* Try to make sure that the high iteration picture is finished before continuing. */
  110.     /* This allows Mand2000 to create the animation MUCH faster.  If you wanted to you */
  111.     /* could change the script so that it loops until the picture is done. */
  112.     if (PROJ.DONE ~= 1) THEN
  113.         REQUESTNOTIFY "Click `Continue' when this|picture finishes calculating."
  114.  
  115.     REQUESTER MAXITERS ON    /* Force it to be up regardless. */
  116.     REQUESTNOTIFY "Now click `Continue' when you have|set max iters to the desired start|value for the animation.|Typically you will want to set it|to the highest value where the|screen is all black."
  117.  
  118.     /* Turn the maxiters requester off, if that's how it started. */
  119.     if (maxitersstate = 0) THEN
  120.         REQUESTER MAXITERS OFF
  121.  
  122.     /* Put a command in the user menu for stopping the movie creation. */
  123.     menu '"------------------------"'
  124.     menu '"Stop Iter Movie"' itermovie stop
  125.  
  126.     INCPAUSE        /* Stop calculations again. */
  127.     SETCLIP("Mand2000FrameNum", 10001)
  128.     /* Tell Mand2000 to call this script whenever a pictures finishes calculating. */
  129.     EVENTACTION PICTUREDONE IterMovie
  130.     GETATTR application stem PROJ
  131.     /* Assume that ADPro is not wanted. */
  132.     SETCLIP("ITERTOADPRONAME")
  133.     /* Then ask if it is. */
  134.     REQUESTRESPONSE "Would you like the frames|written to an anim file|by ADPro?"
  135.     if (RC = 0) THEN DO
  136.         REQUESTSAVEFILE 'title="Iter anim file name."' 'path="RAM:"' 'file="IterAnim"'
  137.         SETCLIP("ITERTOADPRONAME", result)
  138.         blah = GETCLIP("ITERTOADPRONAME")
  139.         END
  140.     if (PROJ.DONE = 1) THEN
  141.         ContinueIterMovie()    /* If the current frame is already finished, save it and go to  */
  142.                     /* the next one.  Otherwise wait for this routine to be called   */
  143.                     /* again when the picture does finish calculating. */
  144.     RETURN 0
  145.  
  146.  
  147.  
  148. StopIterMovie:
  149.     /* Tell Mand2000 not to call this script any more. */
  150.     EVENTACTION PICTUREDONE
  151.     /* Remove the `stop iter movie' menu. */
  152.     CLEARNMENUS 2
  153.     SETCLIP("Mand2000Iters")
  154.     FRAMENUM = GETCLIP("Mand2000FrameNum")
  155.     if (FRAMENUM = "") THEN
  156.         EXIT
  157.     SETCLIP("Mand2000FrameNum")
  158.     AnimName = GETCLIP("ITERTOADPRONAME")
  159.     if (AnimName ~= "") THEN DO
  160.         if ~show('p',"ADPro") THEN
  161.             EXIT
  162.         /* Start sending commands to ADPro. */
  163.         ADDRESS "ADPro"
  164.         /* Specify that we want to save an animation file. */
  165.         SFORMAT Anim
  166.         /* Save as anim frame. */
  167.         SAVE AnimName IMAGE WRAPUP BYTE FASTER
  168.         Why = ADPRO_RESULT
  169.         if (RC ~= 0) THEN DO
  170.             REQUESTNOTIFY "Error in wrap up.|Aborting animation."
  171.             StopIterMovie()
  172.             EXIT
  173.             END
  174.         /* Resume sending commands to Mand2000. */
  175.         ADDRESS
  176.         if (FRAMENUM = 10001) THEN
  177.             REQUESTNOTIFY "Zero frames created."
  178.         else if (FRAMENUM = 10002) THEN
  179.             REQUESTNOTIFY "One frame created."
  180.         else
  181.             REQUESTNOTIFY "Just created a "FRAMENUM - 10001" frame anim.|Use DPaint or View to play it."
  182.         EXIT
  183.         END
  184.     if (FRAMENUM = 10001) THEN
  185.         REQUESTNOTIFY "Zero frames created."
  186.     else if (FRAMENUM = 10002) THEN
  187.         REQUESTNOTIFY "One frame created."
  188.     else
  189.         REQUESTNOTIFY "Just created "FRAMENUM - 10001" iter frames.|Use ADPro or DPaint to make these|into an animation."
  190.     RETURN 0
  191.  
  192.  
  193.  
  194. ContinueIterMovie:
  195.     FRAMENUM = GETCLIP("Mand2000FrameNum")
  196.     SAVEAS "NAME=RAM:ITERFRAME"FRAMENUM 1    /* Save the location and graphics (type 1) of the frame. */
  197.     if (RC ~= 0) THEN DO
  198.         REQUESTNOTIFY "Error in saving frame "FRAMENUM".|Aborting animation."
  199.         StopIterMovie()
  200.         EXIT
  201.         END
  202.     AnimName = GETCLIP("ITERTOADPRONAME")
  203.     if (AnimName ~= "") THEN DO
  204.         if ~show('p',"ADPro") THEN DO
  205.             REQUESTNOTIFY "Error - ADPro is not running.|Aborting animation."
  206.             StopIterMovie()
  207.             EXIT
  208.             END
  209.         /* Start sending commands to ADPro. */
  210.         ADDRESS "ADPro"
  211.         /* Specify that we want to load an IFF file. */
  212.         LFORMAT IFF
  213.         /* Load the last generated frame, don't bother converting to 24 bit. */
  214.         Load "RAM:ITERFRAME"FRAMENUM nopad
  215.         if (RC = 10) THEN DO
  216.             REQUESTNOTIFY "Error in loading to ADPro.|Aborting animation."
  217.             StopIterMovie()
  218.             EXIT
  219.             END
  220.         /* Specify that we want to save an animation file. */
  221.         SFORMAT Anim
  222.         /* Save as anim frame. */
  223.         SAVE AnimName IMAGE APPEND BYTE FASTER
  224.         Why = ADPRO_RESULT
  225.         if (RC ~= 0) THEN DO
  226.             REQUESTNOTIFY "Error in anim save.|Aborting animation."
  227.             StopIterMovie()
  228.             EXIT
  229.             END
  230.         /* Resume sending commands to Mand2000. */
  231.         ADDRESS
  232.         /* At this point the IFF file could be deleted from the RAM disk. */
  233.         END
  234.     FRAMENUM = FRAMENUM + 1
  235.     SETCLIP("Mand2000FrameNum", FRAMENUM)
  236.  
  237.     GETATTR application stem PROJ
  238.     ITERNUM = PROJ.MAXITERS
  239.     ENDITERNUM = GETCLIP("Mand2000IterEnd")
  240.     if (ITERNUM >= ENDITERNUM) THEN DO
  241.         StopIterMovie()
  242.         EXIT
  243.         END
  244.  
  245.     ITERNUM = ITERNUM + IterInc
  246.     if (ITERNUM > SpeedUpPoint) THEN
  247.         ITERNUM = ITERNUM + (ITERNUM - SpeedUpPoint) % IncDivisor
  248.  
  249.     if (ITERNUM >= ENDITERNUM) THEN
  250.         ITERNUM = ENDITERNUM
  251.  
  252.     MAXITERS ITERNUM
  253.     RETURN 0
  254.